package response

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

const (
	successCode      = 0   //成功
	paramErrCode     = 400 //参数错误
	commonErrCode    = 7   // 这个错误，啥意思？
	RefreshTokenCode = 409 //与前端对接，刷新token验证token时用这个验证码返回
)

type response struct {
	Code   int         `json:"code"`
	Data   interface{} `json:"data"`
	Msg    string      `json:"msg"`
	ReqKey string      `json:"reqKey"`
}

func Result(code int, data interface{}, msg string, ctx *gin.Context) {
	ctx.JSON(
		http.StatusOK, response{
			code,
			data,
			msg,
			ctx.GetString("reqKey"),
		},
	)
}
